package lumis.portal.transaction;

import lumis.portal.PortalException;
import lumis.portal.stability.StableMinor;
import lumis.util.ITransaction;

/**
 * Observer that wants to be notificated about an {@link ITransaction}'s 
 * events.
 * <p>
 * Instances of this interface that need to be stateful should not be
 * shared between multiple transactions.
 * 
 * @see AbstractTransactionObserver
 * @version $Revision: 13082 $ $Date: 2011-05-27 16:03:12 -0300 (Fri, 27 May 2011) $
 * @since 4.0.8
 */
@StableMinor(version = "6.0", sinceVersion = "4.0")
public interface ITransactionObserver
{
	/**
	 * Called by the observed transaction just before the commit operation.
	 * @return true to indicate success; false to indicate fail, and cause the 
	 * transaction to cancel commiting.
	 * @throws PortalException
	 * @since 4.0.8
	 */
	public boolean beforeCommit() throws PortalException;

	/**
	 * Called by the observed transaction just after the commit operation.
	 * @throws PortalException
	 * @since 4.0.8
	 */
	public void afterCommit() throws PortalException;

	/**
	 * Called by the observed transaction just before the rollback operation.
	 * @throws PortalException
	 * @since 4.0.8
	 */
	public void beforeRollback() throws PortalException;

	/**
	 * Called by the observed transaction just after the rollback operation.
	 * @throws PortalException
	 * @since 4.0.8
	 */
	public void afterRollback() throws PortalException;
}
